import { baseUrlApi, requestClient, type Result } from '#/api/request';
// 用户数据类型
export interface UserInfoData {
  user_nickname?: string;
  sex?: number;
  birthday?: string;
  user_url?: string;
  signature?: string;
  id?: number;
}

/** 当前管理员个人信息 */
export const getAdminUserInfo = () => {
  return requestClient.get<Result>(baseUrlApi('/admin/my/info'));
};

/**
 * 编辑当前管理员个人信息
 * @param data
 * @returns
 */
export const putAdminUserInfo = (data: UserInfoData) => {
  return requestClient.put<Result>(baseUrlApi('/admin/my/info'), data);
};

/** 获取当前管理员我的邮箱设置 */
export const getAdminUserInfoEmailSetting = () => {
  return requestClient.get<Result>(baseUrlApi('/admin/my/email/setting'));
};

/**
 * 当前管理员我的邮箱设置提交保存
 * @param data
 * @returns
 */
export const putAdminUserInfoEmailSetting = (data?: UserInfoData) => {
  return requestClient.put<Result>(baseUrlApi('/admin/my/email/setting'), data);
};

/**
 * 当前管理员我的邮箱设置测试
 * @param data
 * @returns
 */
export const postAdminUserInfoEmailSettingTest = (data: {
  content: string;
  subject: string;
  to: string;
}) => {
  return requestClient.post<Result>(
    baseUrlApi('/admin/my/email/setting/test'),
    data,
  );
};
